//package com.jyh.service;
//
//import com.jyh.dao.StockDao;
//import com.jyh.entity.Stock;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
///**
// * @author JYH
// * @version 1.0
// * @date 2022/12/8 13:30
// */
//@Service
//public class StockService {
//
//    @Autowired
//    private StockDao stockDao;
//
//    public String decrement(Integer productId){
//        //1.查询商品的库存
//        Stock stock = stockDao.selectById(productId);
//        //2.判断库存是否足够
//        if(stock.getStock()>0){
//            stock.setStock(stock.getStock()-1);
//            int i = stockDao.updateById(stock);
//            System.out.println("商品编号为:" + productId + "的商品库存剩余:" + stock.getStock() + "个");
//            return "商品编号为:" + productId + "的商品库存剩余:" + stock.getStock() + "个";
//        }else {
//            System.out.println("商品编号为:" + productId + "的商品库存不足。");
//            return "商品编号为:" + productId + "的商品库存不足。";
//        }
//    }
//}
